#pragma once
#include "mkvsplitpin.hpp"
#include "graphutil.hpp"

namespace MkvParser
{
    class Segment;
}

namespace MkvSplit
{

class Inpin : public Pin
{
    Inpin(const Inpin&);
    Inpin& operator=(const Inpin&);
    
public:
    explicit Inpin(Filter*);
    
    //void Init();
    //virtual void Final() = 0;

    //IUnknown interface:
    
    HRESULT STDMETHODCALLTYPE QueryInterface(const IID&, void**);
    ULONG STDMETHODCALLTYPE AddRef();
    ULONG STDMETHODCALLTYPE Release();
    
    //IPin interface:

    HRESULT STDMETHODCALLTYPE QueryAccept(const AM_MEDIA_TYPE*);

    HRESULT STDMETHODCALLTYPE Connect(IPin*, const AM_MEDIA_TYPE*);

    //HRESULT STDMETHODCALLTYPE Disconnect();

    HRESULT STDMETHODCALLTYPE ReceiveConnection( 
        IPin*,
        const AM_MEDIA_TYPE*);
        
    HRESULT STDMETHODCALLTYPE QueryInternalConnections( 
        IPin**,
        ULONG*);
        
    HRESULT STDMETHODCALLTYPE EndOfStream();

    HRESULT STDMETHODCALLTYPE BeginFlush();    

    HRESULT STDMETHODCALLTYPE EndFlush();
    
    HRESULT STDMETHODCALLTYPE NewSegment( 
        REFERENCE_TIME,
        REFERENCE_TIME,
        double);
        
protected:
    HRESULT GetName(PIN_INFO&) const;
    HRESULT OnDisconnect();

public:
    GraphUtil::IAsyncReaderPtr m_pReader;    
    GraphUtil::IMemAllocatorPtr m_pAllocator;

};
    
}  //end namespace MkvSplit
